﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using HandyControl.Data;

namespace Sensor.UI.Converters;

public class BoolToParamsEnabled : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ToValue(value);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ToValue(value);
    }


    private static bool ToValue(object value)
    {
        if (value != null && bool.TryParse(value.ToString(), out bool result))
        {
            return !result;
        }
        return false;
    }
}